package com.xxwy.springboot.webflux.util;

import com.xxwy.springboot.webflux.exception.CheckException;

import java.util.stream.Stream;

/**
 * @author xxwy
 * on 2018/8/17 0017
 */
public class CheckUtil {

    private static final String[] INVALD_NAMES = {"ADMIN","gender"};


    /**
     * 校验名字，不成功抛出异常
     * @param name
     */
    public static void checkName(String name){
        Stream.of(INVALD_NAMES).filter(n ->n.equalsIgnoreCase(name))
                .findAny().ifPresent(n ->{
                    throw new CheckException("name",n);
        });

    }
}
